/* primera parte: no hace falta poner nada */
package compiladorsc;
import java_cup.runtime.Symbol;
%%
/* segunda parte: declaramos las directivas y los macros */
%class CalcLexer
%line
%column
%cup
LineTerminator = \r|\n|\r\n
WhiteSpace = {LineTerminator} | [ \t\f]
Variables= ([a-z]|[A-Z])([a-z]*|[A-Z]*|[0-9]*)*
Decimal = [1-9][0-9]*+("."[0-9]+)+|0+("."[0-9]+)+
Entero = 0|[1-9][0-9]*
Cadena = [\"](.|[.|" "|_|a-z|A-Z|0-9])*[\"]
Boleano = verdadero | falso
Tipo = entero | cadena | boleano | decimal | sinTipo

%%
/* tercera parte: declaramos las reglas */
"inicio:" {return new Symbol(sym.INICIO, new token(yycolumn, yyline, yytext()));}
"fin" {return new Symbol(sym.FIN, new token(yycolumn, yyline, yytext()));}
"variables:" {return new Symbol(sym.DECLARACIONVAR, new token(yycolumn, yyline, yytext()));}
":=" {return new Symbol(sym.ASIGNACION, new token(yycolumn, yyline, yytext()));}
"," {return new Symbol(sym.COMA, new token(yycolumn, yyline, yytext()));}
"+" {return new Symbol(sym.MAS, new token(yycolumn, yyline, yytext()));}
"-" {return new Symbol(sym.MENOS, new token(yycolumn, yyline, yytext()));}
"*" {return new Symbol(sym.MULTIPLICACION, new token(yycolumn, yyline, yytext()));}
"/" {return new Symbol(sym.DIVISION, new token(yycolumn, yyline, yytext()));}
"++" {return new Symbol(sym.INCREMENTO, new token(yycolumn, yyline, yytext()));}
"--" {return new Symbol(sym.DECREMENTO, new token(yycolumn, yyline, yytext()));}
";" {return new Symbol(sym.PCOMA,new token(yycolumn, yyline, yytext()));}
"&" {return new Symbol(sym.AND, new token(yycolumn, yyline, yytext()));}
"|" {return new Symbol(sym.OR, new token(yycolumn, yyline, yytext()));}
"(" {return new Symbol(sym.PARENTESISIZQ, new token(yycolumn, yyline, yytext()));}
")" {return new Symbol(sym.PARENTESISDER, new token(yycolumn, yyline, yytext()));}
"imprimir" {return new Symbol(sym.IMPRIMIR, new token(yycolumn, yyline, yytext()));}
"obtener" {return new Symbol(sym.OBTENER, new token(yycolumn, yyline, yytext()));}
"si" {return new Symbol(sym.SI, new token(yycolumn, yyline, yytext()));}
"entonces" {return new Symbol(sym.ENTONCES, new token(yycolumn, yyline, yytext()));}
"si_no" {return new Symbol(sym.SINO, new token(yycolumn, yyline, yytext()));}
"fin_si" {return new Symbol(sym.FINSI, new token(yycolumn, yyline, yytext()));}
"para" {return new Symbol(sym.PARA, new token(yycolumn, yyline, yytext()));}
"hasta" {return new Symbol(sym.HASTA, new token(yycolumn, yyline, yytext()));}
"hacer" {return new Symbol(sym.HACER, new token(yycolumn, yyline, yytext()));}
"fin_para" {return new Symbol(sym.FINPARA, new token(yycolumn, yyline, yytext()));}
"mientras" {return new Symbol(sym.MIENTRAS, new token(yycolumn, yyline, yytext()));}
"fin_mientras" {return new Symbol(sym.FINMIENTRAS, new token(yycolumn, yyline, yytext()));}
{Decimal} {return new Symbol(sym.DECIMAL, new token(yycolumn, yyline, yytext(),2));}
{Entero} { return new Symbol(sym.ENTERO, new token(yycolumn, yyline, yytext(),1)) ;}
{Boleano} {return new Symbol(sym.BOLEANO, new token(yycolumn, yyline, yytext(),3));}
{Tipo} {return new Symbol(sym.TIPO, new token(yycolumn, yyline, yytext()));}
{Variables} {return new Symbol(sym.VARIABLE, new token(yycolumn, yyline, yytext()));}
{Cadena} {String cad=yytext(); cad=cad.substring(1,cad.length()-1); return new Symbol(sym.CADENA, new token(yycolumn, yyline, cad));}
"<" {return new Symbol(sym.MENOR, new token(yycolumn, yyline, yytext()));}
">" {return new Symbol(sym.MAYOR, new token(yycolumn, yyline, yytext()));}
"<=" {return new Symbol(sym.MENORIGUAL, new token(yycolumn, yyline, yytext()));}
">=" {return new Symbol(sym.MAYORIGUAL, new token(yycolumn, yyline, yytext()));}
"==" {return new Symbol(sym.IGUAL, new token(yycolumn, yyline, yytext()));}
"!=" {return new Symbol(sym.NOIGUAL, new token(yycolumn, yyline, yytext()));}
" " {return new Symbol(sym.ESPACIO, new token(yycolumn, yyline, yytext()));}
{WhiteSpace} {}
. {System.err.println("caracter invalido" + yytext() + "["+ yyline + ":"+ yycolumn + "]");}